<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function createPhone(){
    this.name = "手机"
    this.call = function(){
      console.log(this.name + "打电话")
    }
    this.game = function(){
      console.log(this.name + "玩游戏")
    }
  }

  function createPad(){
    this.name = "平板"
    this.game = function(){
      console.log(this.name + "玩游戏")
    }
  }

  function test(o){
    o.game();
    o.call();
  }

  function fn(o){
    o.call = function(){
      console.log("这是一个平板，没有打电话功能")
    }
    return o;
  }

  const p1 = new createPhone();
  const p2 = new createPad();

  test(p1);
  test( fn(p2) );


  
</script>
</html>